package cn.butcher21.window;

import cn.butcher21.utils.BuildScene;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import java.io.File;

/**
 * butcher create in 2021/05/12/2:50
 */
public class SuccessWindow extends Application {
    private Stage stage;

    public SuccessWindow() {
        stage = new Stage();
        try {
            start(stage);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("../view/success.fxml"));
        primaryStage.setScene(new Scene(root, 400, 100));
        primaryStage.initStyle(StageStyle.UNDECORATED);
        primaryStage.show();
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        stage.close();
                    }
                });
            }
        }).start();

    }

    public Stage getStage() {
        return stage;
    }
}
